package com.note.simpleshop.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.type.DateType;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/***
 *@ClaseName:TbCoupon
 *
 *@Decription:
 *
 *@Author: xubingbing
 *
 *@Date:2019/2/28 0028 19:54
 */
@Entity
@Table(name = "tb_coupon", schema = "simpleshop", catalog = "")
@ApiModel(value="优惠劵")
public class TbCoupon {
    public static final String INTERVAL="interval";//固定时间段
    public static final String COUNT_DOWN="countdown";//领取后倒计时
    public static final Integer ACTIVED=1;
    public static final Integer NOT_ACTIVED=0;
    public static final Integer MUTEX=1;
    public static final Integer NOT_NUTEX=0;
    public static final Integer DISCOUNT=1;
    public static final Integer QUOTA=2;
    @ApiModelProperty(value = "优惠劵编号")
    private String id;
    @ApiModelProperty(value = "优惠劵名称")
    private String name;
    @ApiModelProperty(value = "优惠方式")
    private String preferentialWay;
    @ApiModelProperty(value = "折扣")
    private Double discount;
    @ApiModelProperty(value = "额度")
    private BigDecimal quota;
    @ApiModelProperty(value = "是否互斥")
    private Integer overlying;
    @ApiModelProperty(value = "总数")
    private Integer total;
    @ApiModelProperty(value = "已使用")
    private Integer used;
    @ApiModelProperty(value = "已经领取")
    private Integer drawed;
    @ApiModelProperty(value = "领取限制")
    private Integer drawLimit;
    @ApiModelProperty(value = "限制金额")
    private BigDecimal restrictionMoney;
    @ApiModelProperty(value = "生效时间")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date eifTime;
    @ApiModelProperty(value = "过期时间")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date expireTime;
    @ApiModelProperty(value = "备注")
    private String remark;
    @JsonIgnore
    private Integer isDelete;
    @ApiModelProperty(value = "领取后n天有效")
    private Integer countDownDay;
    @ApiModelProperty(value = "优惠劵编码")
    private String code;
    @ApiModelProperty(value = "生效日期类型(interval,countdown)")
    private String dateType;
    @ApiModelProperty(value = "普通类型（用户领取）normal,注册类型register,活动类型campaign")
    private String type;
    @ApiModelProperty(value = "渠道")
    private String channel;
    @JsonIgnore
    private Integer active;
    @JsonIgnore
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    @Basic
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "active")
    public Integer getActive() {
        return active;
    }

    public void setActive(Integer active) {
        this.active = active;
    }

    @Basic
    @Column(name = "channel")
    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    @Basic
    @Column(name = "type")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Basic
    @Column(name = "date_type")
    public String getDateType() {
        return dateType;
    }

    public void setDateType(String dateType) {
        this.dateType = dateType;
    }

    @Basic
    @Column(name = "code")
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Basic
    @Column(name = "count_down_day")
    public Integer getCountDownDay() {
        return countDownDay;
    }
    public void setCountDownDay(Integer countDownDay) {
        this.countDownDay = countDownDay;
    }

    @Basic
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Basic
    @Column(name = "is_delete")
    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    @Id
    @Column(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "preferential_way")
    public String getPreferentialWay() {
        return preferentialWay;
    }

    public void setPreferentialWay(String preferentialWay) {
        this.preferentialWay = preferentialWay;
    }

    @Basic
    @Column(name = "discount")
    public Double getDiscount() {
        return discount;
    }

    public void setDiscount(Double discount) {
        this.discount = discount;
    }

    @Basic
    @Column(name = "quota")
    public BigDecimal getQuota() {
        return quota;
    }

    public void setQuota(BigDecimal quota) {
        this.quota = quota;
    }

    @Basic
    @Column(name = "overlying")
    public Integer getOverlying() {
        return overlying;
    }

    public void setOverlying(Integer overlying) {
        this.overlying = overlying;
    }

    @Basic
    @Column(name = "total")
    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    @Basic
    @Column(name = "used")
    public Integer getUsed() {
        return used;
    }

    public void setUsed(Integer used) {
        this.used = used;
    }

    @Basic
    @Column(name = "drawed")
    public Integer getDrawed() {
        return drawed;
    }

    public void setDrawed(Integer drawed) {
        this.drawed = drawed;
    }

    @Basic
    @Column(name = "draw_limit")
    public Integer getDrawLimit() {
        return drawLimit;
    }

    public void setDrawLimit(Integer drawLimit) {
        this.drawLimit = drawLimit;
    }

    @Basic
    @Column(name = "restriction_money")
    public BigDecimal getRestrictionMoney() {
        return restrictionMoney;
    }

    public void setRestrictionMoney(BigDecimal restrictionMoney) {
        this.restrictionMoney = restrictionMoney;
    }

    @Basic
    @Column(name = "eif_time")
    public Date getEifTime() {
        return eifTime;
    }

    public void setEifTime(Date eifTime) {
        this.eifTime = eifTime;
    }

    @Basic
    @Column(name = "expire_time")
    public Date getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(Date expireTime) {
        this.expireTime = expireTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TbCoupon tbCoupon = (TbCoupon) o;
        return Objects.equals(id, tbCoupon.id) &&
                Objects.equals(name, tbCoupon.name) &&
                Objects.equals(preferentialWay, tbCoupon.preferentialWay) &&
                Objects.equals(discount, tbCoupon.discount) &&
                Objects.equals(quota, tbCoupon.quota) &&
                Objects.equals(overlying, tbCoupon.overlying) &&
                Objects.equals(remark, tbCoupon.remark) &&
                Objects.equals(total, tbCoupon.total) &&
                Objects.equals(used, tbCoupon.used) &&
                Objects.equals(drawed, tbCoupon.drawed) &&
                Objects.equals(drawLimit, tbCoupon.drawLimit) &&
                Objects.equals(restrictionMoney, tbCoupon.restrictionMoney) &&
                Objects.equals(eifTime, tbCoupon.eifTime) &&
                Objects.equals(expireTime, tbCoupon.expireTime)&&
                Objects.equals(isDelete, tbCoupon.isDelete)&&
                Objects.equals(channel, tbCoupon.channel)&&
                Objects.equals(dateType,tbCoupon.dateType)&&
                Objects.equals(active, tbCoupon.active);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, preferentialWay, discount, quota, overlying, total, used, drawed, drawLimit, restrictionMoney, eifTime, expireTime,isDelete,dateType,channel,active);
    }
}
